package Sort;

import java.util.Arrays;

public class SelectionSort {
    public void selectSort(int[] nums) {
        int n = nums.length;
        for (int i = 0; i < n - 1; i++) {
            int index = i;
            for (int j = i + 1; j < n; j++) {
                if (nums[j] < nums[index]) {
                    index = j;
                }
            }
            int temp = nums[i];
            nums[i] = nums[index];
            nums[index] = temp;
        }
    }

    public static void main(String[] args) {
        SelectionSort sort = new SelectionSort();
        int[] nums = new int[] { 4, 4, 3, 1, 5, 2 };
        sort.selectSort(nums);
        System.out.println(Arrays.toString(nums));
    }
}
